//
//  ScrollChoiceWeapons.m
//  DoodleGunnyChipMunk
//
//  Created by QuickSoluion on 5/6/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ScrollChoiceWeapons.h"

CGRect _itemScroll={430.0f,570.0f,600.0f,100.0f};
int Choice_WhichItem=1;
@implementation ScrollChoiceWeapons
@synthesize _world;


-(id)init
{
	if(self =[super init])	
	{
		
		//[self InitListBar];
	}
	return self;
}
-(void)InitListBar
{
	[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
	[UIView setAnimationBeginsFromCurrentState:YES];
	//[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
	[UIView setAnimationsEnabled:YES];
	[UIView setAnimationDuration:0.5];
	
	
	ItemScroll = [[UIScrollView alloc] initWithFrame:_itemScroll];
	
	
	
	ItemScroll.tag = 333;
	//jScrollView.contentSize = CGSizeMake(250,550);///250 +- anh huong den so dong duoc them vo theo ct: 250*i
	ItemScroll.pagingEnabled = YES;
	[ItemScroll setBackgroundColor:[UIColor greenColor]];
	ItemScroll.alpha=0;
	ItemScroll.transform= CGAffineTransformRotate(ItemScroll.transform, M_PI*3/2);
	// set visiblefor jscrollView
	[[[[CCDirector sharedDirector] openGLView] window] addSubview:ItemScroll];
	ItemScroll.alpha=1;
	[UIView commitAnimations];
	
	
	
	
	///---------------Add background--------------------------------------------------	
	UIImage* image = [UIImage imageNamed:@"Tred.png"];
	TredView = [[UIImageView alloc] initWithImage:image];	
	TredView.transform= CGAffineTransformRotate(TredView.transform, M_PI*1/2);
	TredView.frame=CGRectMake(0,0,1000.0f,100);	
	[ItemScroll addSubview:TredView];
	//[TredView release];
	//////-------item GOLF----------------
	
	for(int i=1;i<3;i++)
	{
		UIImage* PictureGolf_1 =[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"Bom_%d",i] ofType:@"png"]];
		UIButton *UiView_BTN=[[UIButton buttonWithType:UIButtonTypeCustom]retain];
		[UiView_BTN setImage:PictureGolf_1 forState:UIControlStateNormal];
		UiView_BTN.frame = CGRectMake(0, 0, 60, 60);
		UiView_BTN.alpha = 1;
		[UiView_BTN addTarget:self action:@selector(select_item:) forControlEvents:UIControlEventTouchUpInside];
		UiView_BTN.transform= CGAffineTransformRotate(UiView_BTN.transform, M_PI);
		UiView_BTN.center = CGPointMake(420+70*i, 40);
		UiView_BTN.tag=200+i;
		ItemScroll.contentSize =CGSizeMake(600 +i*190 ,60 );
		//TredView.contentSize =CGSizeMake
		TredView.frame=CGRectMake(0,0,800.0f+i*190,100);	
		
		[ItemScroll addSubview:UiView_BTN];
		
		[PictureGolf_1 release];
		[UiView_BTN release];
	}
	
	
	
	
	
	
	
}
-(void)select_item:(id)id_sender
{
	UIButton* btn = (UIButton *)id_sender;
	int Which_item=btn.tag-200;
	
	
	
	
	switch (Which_item) {
		case 1:
			NSLog(@"select BOMB");
			break;
		case 2:
			NSLog(@"select GUN");
			break;
		default:
			break;
	}
	
	Choice_WhichItem=Which_item;
	[_world SetWeaponChoiced:Choice_WhichItem];
}

-(int)WhichItemChoiced
{
	return Choice_WhichItem;
}


-(void)_show
{
	
	ItemScroll.alpha=1;
	
	
}
-(void)_hide
{
	ItemScroll.alpha=0;
	
}

@end
